package com.webbei.product.dao.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import com.webbei.pojo.Advertisement;
import com.webbei.pojo.BgPic;
import com.webbei.pojo.Customs;
import com.webbei.pojo.DengLu;
import com.webbei.pojo.Designers;
import com.webbei.product.action.OtherProduct;
import com.webbei.product.action.Product;
import com.webbei.product.action.ProductInfo;
import com.webbei.product.dao.ProductDao;

public class ProductDaoImpl implements ProductDao {

	private SqlSession session;
	
	public SqlSession getSession() {
		return session;
	}
	public void setSession(SqlSession session) {
		this.session = session;
	}
	
	//��ȡ��Ʒ��Ϣ
	public List<Product> getProducts() {
		List<Product>products = session.selectList("Products.getAllProducts");
		return products;
	}
	@Override
	public ProductInfo getProductById(int id) {
		
		ProductInfo pi = (ProductInfo) session.selectOne("Products.getProductById",id);
		
		return pi;
	}
	@Override
	public List<OtherProduct> getOtherProducts(String mark) {
		return session.selectList("cust.getOtherProduct",mark);
	}
	@Override
	public List<Advertisement> getAllAdvertisements() {
		
		return session.selectList("advertisment.getShow");
	}
	@Override
	public List<Customs> getCustomByBgPic(int productId) {
		
		return session.selectList("cust.getCustomByBgPic",productId);
	}
	@Override
	public Designers getDesignerByUsername(String username) {
		
		return (Designers) session.selectOne("designers.getthedesignersbymail",username);
	}
	@Override
	public List<String> getBgPicByUrl(String url) {
		
		return session.selectList("BgPic.getBgPicByUrl",url);
	}
	@Override
	public String getTypesPicByName(String seriesName) {
		// TODO Auto-generated method stub
		return (String) session.selectOne("cartype.getOneTypesPicByName",seriesName);
	}
	@Override
	public Map<String, String> getDengLuKey(String name) {
		System.out.println(name);
		return session.selectMap("label.getDengLuKey", name);
	}
	@Override
	public DengLu getDengLuByName(String name) {
		// TODO Auto-generated method stub
		return (DengLu) session.selectOne("label.getDengLuByName",name);
	}
}
